package cn.liumouren.jzxd.dao;

import cn.liumouren.jzxd.entity.Likes;
import cn.liumouren.jzxd.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Freeman Liu
 * @email llw599502537@gmail.com
 * @date 2020-10-30 16:28:20
 */
@Mapper
public interface LikesDao extends BaseMapper<Likes> {


    /**
     * 以查询到的 user_id 为参数，来执行 UserDao 中的 getUserById 方法
     *
     * @param zoneId
     * @return
     */
    @Select("SELECT * FROM tb_likes WHERE zone_id = #{zoneId}")
    @Results(id = "likesMap",value = {
            @Result(property = "user",
                    javaType = User.class,
                    column = "user_id",
                    one = @One(select = "cn.liumouren.jzxd.dao.UserDao.getUserById"))
    })
    List<Likes> getAllLikesByZoneId(String zoneId);
}
